perm filename WHOIS.FAI[S,NET] blob sn#875653 filedate 1989-07-26 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	 A B C P PDLEN PDL CMDLIN SVRNAM NAMSTAN NAMNIC WISPRT NIORTS ERRHAN ERRTNS HSTTAB WHOIS SCAN1 SWITCH SWNIC0 SWNIC SWSTAN PROMPT GETCMD GETCM1 GETCM2 GETCM3 SEND1 SEND2 RECV1 HSTERR
C00008 ENDMK
C⊗;
;⊗ A B C P PDLEN PDL CMDLIN SVRNAM NAMSTAN NAMNIC WISPRT NIORTS ERRHAN ERRTNS HSTTAB WHOIS SCAN1 SWITCH SWNIC0 SWNIC SWSTAN PROMPT GETCMD GETCM1 GETCM2 GETCM3 SEND1 SEND2 RECV1 HSTERR

Comment ⊗ History:

01 Mar 87  JJW	Initial implementation.
10 Mar 87  ME	Added NICNAME command, like /NIC.
13 Jul 87  ME	Changed "Unknown host" error message to explain that
		it is the whois server host whose name is unknown.
		Converted server name lookup to use domain system.
26 Jul 89  ME	Changed NIC host name from SRI-NIC.ARPA to NIC.DDN.MIL.

⊗;end of history (please list changes)

;BUG: This code doesn't accept a switch when started with "START;" because
;     SCAN1 looks for "/" only BEFORE the delimiter (";" in this case).
;     So you would have to say "START /N;host" -- which WAITS won't accept.

A←1
B←2
C←3
P←17
PDLEN←20

PDL:	BLOCK PDLEN
CMDLIN:	BLOCK 20
SVRNAM:	BLOCK 1			;Pointer to server name

NAMSTAN:ASCIZ/Argus.Stanford.EDU/
NAMNIC:	ASCIZ/NIC.DDN.MIL/

WISPRT←←=43			;TCP port number for WHOIS

NIORTS←←-1			;include I/O routines
ERRHAN←←-1			;include automagic error handling
ERRTNS←←-1			;include error routines
HSTTAB←←-1			;include host table routines
DOMRTS←←-1			;include domain code

.INSERT NETWRK.FAI[S,NET]

WHOIS:	RESET
	MOVE P,[IOWD PDLEN,PDL]
	SETZM ERRCLR↑		;suppress CLRBFI by NETWRK on any error
	MOVEI A,0
	JBTSTS A,
	TLNN A,10000		;JLOG
	OUTSTR [BYTE (7)15,12]
	MOVEI A,NAMSTAN		;Default server name
	MOVEM A,SVRNAM
	MOVEI A,WISPRT		;Set up port for CONECT
	MOVEM A,CONFPR
	MOVE B,[POINT 7,CMDLIN]
	MOVEI C,";"		;Delimiter to scan for (unless system command)
	RESCAN
	INCHWL A
	CAIE A,"N"		;NICNAME command
	CAIN A,"n"
	JRST SWNIC0
	CAIE A,"W"		;WHOIS command?
	CAIN A,"w"
	MOVEI C," "
	CAIE A,"T"		;or TEST command?
	CAIN A,"t"
	MOVEI C," "
SCAN1:	INCHWL A
	CAIN A,(C)
	JRST GETCMD		;Found delimiter, get command
	CAIN A,"/"
	JRST SWITCH
	CAIE A,12
	CAIN A,175
	JRST PROMPT
	JRST SCAN1

SWITCH:	MOVEI C," "		;Set delimiter following switch
	INCHWL A
	CAIE A,"N"
	CAIN A,"n"
	JRST SWNIC
	CAIE A,"S"
	CAIN A,"s"
	JRST SWSTAN
	OUTSTR [ASCIZ/Unknown switch/]
	CLRBFI
	EXIT

SWNIC0:	MOVEI C," "		;set delimiter
SWNIC:	MOVEI A,NAMNIC
	MOVEM A,SVRNAM
	JRST SCAN1

SWSTAN:	MOVEI A,NAMSTAN
	MOVEM A,SVRNAM
	JRST SCAN1

PROMPT:	OUTSTR [ASCIZ/Ident: /]
GETCMD:	INCHWL A
	CAIE A," "		;Ignore leading blanks
	CAIN A,11
	JRST GETCMD
GETCM1:	CAIN A,15
	JRST GETCM2
	CAIE A,12
	CAIN A,175
	JRST GETCM3
	IDPB A,B		;Store a command char
GETCM2:	INCHWL A
	JRST GETCM1

GETCM3:	CAMN B,[POINT 7,CMDLIN]
	JRST PROMPT		;Don't allow empty text
	MOVEI A,0
	IDPB A,B

;	SKIPN HSTADR
;	PUSHJ P,ATTHST		;Attach host table upper segment
	MOVE 0,SVRNAM
;	PUSHJ P,HSTNAM		;(host table lookup)
	SETZM DVERBOSE		;suppress some typeout by NETWRK
	PUSHJ P,NAMADR		;lookup host name in domain system
	 JRST HSTERR
	 JRST HSTERR
;	MOVEM 0,HOST
	MOVE A,(1)		;get first address
	MOVEM A,HOST		;store server address
	OUTSTR [ASCIZ/Accessing database at /]
	OUTSTR @SVRNAM
	OUTSTR [ASCIZ/ ...
/]
	PUSHJ P,CONECT
	MOVE B,[POINT 7,CMDLIN]
SEND1:	ILDB 0,B
	JUMPE 0,SEND2
	PUSHJ P,NETOCH
	JRST SEND1

SEND2:	MOVEI 0,15		;Send CRLF
	PUSHJ P,NETOCH
	MOVEI 0,12
	PUSHJ P,NETOCH
	PUSHJ P,NETSND

RECV1:	PUSHJ P,NETICW
	OUTCHR 0
	JRST RECV1

HSTERR:	OUTSTR [ASCIZ/Unknown whois server host (/]
	OUTSTR (1)		;type error message from NETWRK
	OUTSTR [ASCIZ/) -- /]
	OUTSTR @SVRNAM		;type server name we looked up
	EXIT

	END WHOIS